package com.tz.crm.service.impl;

import com.tz.crm.dao.AreaDao;
import com.tz.crm.entity.Area;
import com.tz.crm.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用于页面的省市地区的级联查询服务类
 */
@Service
@Transactional
public class AreaServiceImpl extends BaseServiceImpl<Area, String> implements AreaService {

    @Autowired
    private AreaDao areaDao;

    /**
     * 有参构造
     *
     * @param areaDao 注入的 AreaDao 组件
     */
    @Autowired
    public AreaServiceImpl(AreaDao areaDao) {
        this.areaDao = areaDao;
        super.setBaseDao(areaDao);
    }

    @Override
    public Area getById(String id) {
        return areaDao.getById(id);
    }

    @Override
    public List<Area> getAreaWithChildren(String name) {
        return areaDao.getAreaWithChildren(name);
    }

    @Override
    public Area getByName(String name) {
        return areaDao.getByName(name);
    }

    @Override
    public List<Area> getByLevel(int level) {
        return areaDao.getByLevel(level);
    }

    @Override
    public List<Area> getChildrenByParentId(String id) {
        List<Area> list = areaDao.getChildrenByParentId(id);
        return list;
    }
}
